package com.hmc.modules.sjfx.service.tpmmmba.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hmc.common.service.impl.CrudServiceImpl;
import com.hmc.common.constant.Constant;
import com.hmc.modules.sjfx.dao.tpmmmba.TpmmmbaDao;
import com.hmc.modules.sjfx.dto.sjfx.SphAndWglhDTO;
import com.hmc.modules.sjfx.dto.tpmmmba.TpmmmbaDTO;
import com.hmc.modules.sjfx.entity.tpmmmba.TpmmmbaEntity;
import com.hmc.modules.sjfx.service.tpmmmba.TpmmmbaService;
import com.hmc.modules.security.user.SecurityUser;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import static java.util.stream.Collectors.toCollection;

import java.util.Comparator;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.TreeSet;

import static java.util.stream.Collectors.collectingAndThen;

/**
 * 钢板上料实绩表
 *
 * @author hmc wengxiulinluman@qq.com
 * @since 3.0 2024-01-11
 */
@Service
public class TpmmmbaServiceImpl extends CrudServiceImpl<TpmmmbaDao, TpmmmbaEntity, TpmmmbaDTO> implements TpmmmbaService {

    @Autowired
    private TpmmmbaDao tpmmmbaDao;

    @Override
    public QueryWrapper<TpmmmbaEntity> getWrapper(Map<String, Object> params){
        QueryWrapper<TpmmmbaEntity> wrapper = new QueryWrapper<>();


        return wrapper;
    }

    /**
     * 查询钢板上料实绩试批号SAMPLE_LOT_NO和外购炉号ORIGIN_HEAT_NO
     * @return
     */
    @Override
    public List<SphAndWglhDTO> queryTpmmmbaBySphAndWglh() {
        List<SphAndWglhDTO> sphAndWglhDTOS = tpmmmbaDao.queryTpmmmbaBySphAndWglh();
//        List<SphAndWglhDTO> collect = sphAndWglhDTOS.stream().collect(collectingAndThen(toCollection(() -> new TreeSet<>(Comparator.comparing(SphAndWglhDTO::getSampleLotNo))), ArrayList::new));
        return sphAndWglhDTOS;
    }

    /**
     * 查询螺旋上料实绩表试批号SAMPLE_LOT_NO和外购炉号ORIGIN_HEAT_NO
     * @return
     */
    @Override
    public List<SphAndWglhDTO> queryTpmmmbaBySphAndWglhDA() {

        List<SphAndWglhDTO> sphAndWglhDTOS = tpmmmbaDao.queryTpmmmbaBySphAndWglhDA();
        List<SphAndWglhDTO> collect = sphAndWglhDTOS.stream().collect(collectingAndThen(toCollection(() -> new TreeSet<>(Comparator.comparing(SphAndWglhDTO::getSampleLotNo))), ArrayList::new));
        return collect;
    }
}